import axios from 'axios';
import store from '../store/index';

// axios.defaults.headers.post['Content-Type'] =
//   'application/x-www-form-urlencoded';

// 请求拦截器
axios.interceptors.request.use((config) => {
  config.headers.Authorization = store.state.token;
  return config;
});
// 响应拦截器
axios.interceptors.response.use(
  function (response) {
    //只返回数据
    return response.data;
  },
  function (error) {
    return Promise.reject(error);
  }
);

export default axios;
